using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using MobileClient.UIProcessService;

namespace MobileClient
{
	/// <summary>
	/// Summary description for ctlDateEntry.
	/// </summary>
	public class ctlDateEntry : Control
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private DateTimePicker datePicker;

		private DateEntry m_objEntry;

		public ctlDateEntry()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			m_objEntry = null;
		}

		public DateEntry Entry
		{
			get { return m_objEntry; }
			set { m_objEntry = value; }
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if( components != null )
					components.Dispose();
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.datePicker = new DateTimePicker();
			// 
			// datePicker
			// 
			this.datePicker.Format = DateTimePickerFormat.Long;
			this.datePicker.Location = new System.Drawing.Point(18, 66);
			this.datePicker.Size = new System.Drawing.Size(212, 20);
			// 
			// ctlDateEntry
			// 
			this.Controls.Add(this.datePicker);
			this.Size = new System.Drawing.Size(236, 152);
		}
		#endregion

		public void LoadSettings()
		{
			if(m_objEntry != null)
			{
                if (String.IsNullOrEmpty(m_objEntry.Date))
                {
                    datePicker.Value = DateTime.Today;
                }
                else
                {
                    datePicker.Value = Convert.ToDateTime(m_objEntry.Date);
                }
			}
		}

		public void SaveSettings()
		{
			if(m_objEntry != null)
			{
				m_objEntry.Date = datePicker.Value.ToShortDateString();
			}
		}
	}
}
